package b1.scenes.home
{
	import b1.controls.basic.BasicButton;
	import b1.controls.basic.BasicMessage;
	import b1.net.*;
	
	import flash.events.MouseEvent;

	public class PlusButton extends BasicButton
	{
		public var index:int;
		private var addNum:int;
		private var tip:BasicMessage;
		private var addString:String;
		
		public function PlusButton(index:int, addNum:int, addString:String)
		{
			var PlusImage:Class = ResourceHelper.getInstance().getClassByName("PlusImage");
			this.index = index;
			this.addNum = addNum;
			this.addString = addString;
			super(PlusImage, null);
			addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
			var string:String = "单击技能点减1\n" + addString + "增加: " + addNum;
//			tip = new BasicMessage(string.length * 10, 50, string);
			tip = new BasicMessage(130, 50, string);
			tip.x = this.x + this.width + 5;
			tip.y = this.y + (this.height - tip.height) / 2;
			this.parent.addChild(tip);
		}
		
		private function onMouseOut(event:MouseEvent):void
		{
			if (null !=  tip && null != tip.parent)
        	{
        		tip.parent.removeChild(tip);
        	}
		}
	}
}